package  {
	import org.flixel.*;
	
	public class BouncerEnemy extends FlxSprite {
		public function BouncerEnemy() {
			super();
			this.loadGraphic(BouncerEnemyImg, true, true, 32, 32);
			this.scale.x = 0.5;
			//this.maxVelocity = new FlxPoint(300, 300);
		}
		
		override public function update():void {
			if (!this.active) return;
			//if (!this._isCreated) {
				this.frame = uint((this.y / PlayState.LEVEL_HEIGHT) * 4);
				//this._isCreated = true;
			//}
			if (this._timer < 2)
				this.scale.x += FlxG.elapsed;
			if (this._timer >= 2)
				this.scale.x -= FlxG.elapsed;
			if (this._timer >= 4)
				this._timer = 0;
			this._timer += FlxG.elapsed;
			super.update();
		}
		
		override public function hitRight(Contact:FlxObject, Velocity:Number):void {
			this.velocity.x = -this.velocity.x;
		}
		
		override public function hitLeft(Contact:FlxObject, Velocity:Number):void {
			this.velocity.x = -this.velocity.x;
		}
		
	[Embed(source = '../content/Enemies.png')] 
		private var BouncerEnemyImg:Class;
		private var _isCreated:Boolean = false;
		private var _timer:Number = 0;
	}
}